//防抖函数
function debounce(fn, delay) {
  let timer = null
  return function () {
    let that = this
    let args = arguments
    clearTimeout(timer)
    timer = setTimeout(function () {
      fn.apply(that, args)
    }, delay)
  }
}

//节流函数
function throtle(fn,delay) {
  let pre = Date.now()
  return function () {
    let that = this
    let args = arguments
    let now = Date.now()
    if (pre - now >= delay) {
      fn.apply(that, args)
      pre = Date.now()
    }
  }
}
